package com.csweimei.rentmanagementtreasure.enterprise.viewModel;

import static com.csweimei.rentmanagementtreasure.base.AppConfig.BUNDLE_KEY;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.csweimei.rentmanagementtreasure.base.AppConfig;
import com.csweimei.rentmanagementtreasure.enterprise.act.VipActivity;
import com.csweimei.rentmanagementtreasure.http.entity.BrokerCustomBean;
import com.csweimei.rentmanagementtreasure.tenant.ui.act.customer.CustomerInfoActivity;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.base.MultiItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.utils.ToastUtils;

public class BCustomItemVM extends MultiItemViewModel {
    public BCustomItemVM(@NonNull BaseViewModel viewModel) {
        super(viewModel);
    }

    public ObservableField<BrokerCustomBean.DataDTO> info = new ObservableField<>();
    public void setData(BrokerCustomBean.DataDTO custom) {
        info.set(custom);
    }

    public BindingCommand lookClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            if (AppConfig.isEntVip()){
                Bundle intent = new Bundle();
                intent.putString(BUNDLE_KEY,info.get().getId()+"");
                intent.putString(AppConfig.BUNDLE_KEY2,"ent");
                viewModel.startActivity(CustomerInfoActivity.class,intent);
            }else {
                ToastUtils.showShort("您还未开通企业服务，请前往购买相关服务");
                viewModel.startActivity(VipActivity.class);
            }

        }
    });
}
